package com.dragon.logical.service.avttendance.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dragon.logical.service.auth.impl.TasksServiceImpl;
import com.dragon.repository.entity.QuartzJob;
import com.dragon.repository.mapper.QuartzJobMapper;
import com.dragon.logical.service.avttendance.IQuartzJobService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sy
 * @since 2023-07-17
 */
@Service
public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob> implements IQuartzJobService {

    @Autowired
    QuartzJobMapper quartzJobMapper;
    @Autowired
    TasksServiceImpl tasksService;

    @Override
    public List<QuartzJob> getJobList() {
        QueryWrapper<QuartzJob> wrapper = new QueryWrapper<>();
        List<QuartzJob> quartzJobs = quartzJobMapper.selectList(wrapper);
        return quartzJobs;
    }

    @Override
    public void addJob(QuartzJob quartzJob) {
        quartzJob.setCreateTime(DateUtil.date());
        quartzJobMapper.insert(quartzJob);
        //tasksService.addSchedule();
    }

    @Override
    public void updateJob(QuartzJob quartzJob) {
        quartzJobMapper.updateById(quartzJob);
    }

    @Override
    public void deleteJob(Integer id) {
        quartzJobMapper.deleteById(id);
    }
}
